﻿
Namespace PL.MESSDK
    Public Class SpecificationAttribute_PL
        Inherits PLBase
        Implements IPLProcess

        Public Property SpecificationRevId_FK As Guid?

        Private _aQueryName As String

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
            _aQueryName = queryName
        End Sub

        Public Sub New()
            MyBase.New()
        End Sub


        Sub OnRowUpdating(ByVal sender As Object, ByVal e As SqlRowUpdatingEventArgs) Handles MetaDataTable.OnRowUpdating
        End Sub

        Public Overrides Function Delete() As Boolean
            'Throw New NotImplementedException("Delete To Come...")
            Return False
        End Function

        Public Overrides Function Validate() As Boolean
            'Throw New NotImplementedException("Validate To Come...")
            Return True
        End Function

        Public Function BatchRecords(dataRow() As System.Data.DataRow) As Boolean Implements IPLProcess.BatchRecords
            Return True
        End Function

        Public Function CurrentRecord(dataRow As System.Data.DataRow) As Boolean Implements IPLProcess.CurrentRecord
            Return True
        End Function

        Public Overrides Sub ValidateRow(row As DataRow)
            row.ClearErrors()

            If row.Table.Columns.Contains("SpecGroupID_FK") Then
                If IsDBNull(row("SpecGroupID_FK")) Then
                    row.SetColumnError("SpecGroupID_FK", "Mandatory")
                End If
            End If
            

            If row.HasErrors Then
                row.RowError = "Please check your columns, a validation error occur"
            End If
        End Sub

        Public Function NewRecord(dataRow As System.Data.DataRow) As Boolean Implements IPLProcess.NewRecord
            'Si on arrive d'un TreeList...
            If SpecificationRevId_FK IsNot Nothing Then
                dataRow("SpecificationRevId_FK") = SpecificationRevId_FK
            End If
            dataRow("SpecificationAttributeId") = Guid.NewGuid
            dataRow("SpecList") = 0
            Return True
        End Function
    End Class
End Namespace
